<template>
  <div class="collect">
    <!-- Add a static page for my favorite module -->
    <div class="collect-header">
      <div class="collect-title">
        <i class="el-icon-collection-tag" style="color: #ff6700;"></i>
        我的收藏
      </div>
    </div>
    <div class="content">
      <div class="goods-list" v-if="collectList.length > 0">
        <MyList :list="collectList" :isDelete="true"></MyList>
      </div>
      <!-- 收藏列表为空的时候显示的内容 -->
      <div v-else class="collect-empty">
        <div class="empty">
          <h2>您的收藏还是空的！</h2>
          <p>快去购物吧！</p>
        </div>
      </div>
      <!--  收藏列表为空的时候显示的内容END -->
    </div>
  </div>
</template>
<script>
import MyList from '@/components/MyList'

export default {
  components: {
    MyList
  },
  data() {
    return {
      collectList: []
    }
  },
  activated() {
    // 获取收藏数据
    this.$axios
      .post('/user/collect/getCollect', {
        user_id: this.$store.getters.getUser.user_id
      })
      .then((res) => {
        if (res.data.code === '001') {
          this.collectList = res.data.collectList
        }
      })
      .catch((err) => {
        return Promise.reject(err)
      })
  }
}
</script>
